<template>
	<div class="app">
		<h2>我是App组件（父组件）</h2>
		<h3>School组件（子组件）给我的学校名是：{{xuexiaoMing}}</h3>
		<hr>
		<!-- <School @getName="getName"/> -->
		<School ref="school" />
	</div>
</template>

<script>
	import School from './components/2_自定义事件_子传父.vue'
	export default {
		name: 'App',
		components: {
			School
		},
		data() {
			return {
				xuexiaoMing: ''
			}
		},
		methods: {
			getName(val) {
				this.xuexiaoMing = val;
			}
		},
		mounted() {
			this.$refs.school.$on('getName', this.getName)
		}
	}
</script>

<style>
	.app {
		background-color: gray;
		padding: 20px;
	}
</style>